<template>
    <div class="business-create-template">
        <el-button class="return" type="text" @click="jumpToDefault"><i class="fa fa-angle-left mr5"></i>返回</el-button>
        <h4 class="header">编辑机构信息</h4>
        <div class="content">
            <div class="filter-section">
                <span class="fl title">基本信息</span>
                <span class="fr gray">注：带有*为必填项</span>
            </div>
            <div class="institution-form">
                <el-form :model="ruleForm" :rules="rules" ref="ruleForm" label-width="100px">
                    <el-form-item label="机构名称" prop="instituName">
                        <el-input v-model="ruleForm.insitituName" size="mini"></el-input>
                    </el-form-item>
                    <el-form-item label="机构地址" prop="instituAddress">
                        <el-input v-model="ruleForm.instituAddress" size="mini"></el-input>
                    </el-form-item>
                    <el-form-item label="联系人" prop="contact">
                        <el-input v-model="ruleForm.contact" size="mini"></el-input>
                    </el-form-item>
                    <el-form-item label="手机" prop="telephone">
                        <el-input v-model="ruleForm.telephone" size="mini"></el-input>
                    </el-form-item>
                    <el-form-item label="电话" prop="workPhone">
                        <el-input v-model="ruleForm.workPhone" size="mini"></el-input>
                    </el-form-item>
                    <el-form-item label="国家" prop="country">
                        <el-input v-model="ruleForm.country" size="mini"></el-input>
                    </el-form-item>
                    <el-form-item label="省份" prop="provinces">
                        <el-input v-model="ruleForm.provinces" size="mini"></el-input>
                    </el-form-item>
                    <el-form-item label="市名" prop="city">
                        <el-input v-model="ruleForm.city" size="mini"></el-input>
                    </el-form-item>
                    <el-form-item label="邮编" prop="postcode">
                        <el-input v-model="ruleForm.postcode" size="mini"></el-input>
                    </el-form-item>
                    <el-form-item label="网站" prop="website">
                        <el-input v-model="ruleForm.website" size="mini"></el-input>
                    </el-form-item>
                    <el-form-item label="机构级别" prop="institutionLevel">
                        <el-select v-model="ruleForm.institutionLevel" placeholder="请选择机构级别" size="mini">
                            <el-option label="区域一" value="shanghai"></el-option>
                            <el-option label="区域二" value="beijing"></el-option>
                        </el-select>
                    </el-form-item>
                    <el-form-item label="行业类别" prop="industryCategory">
                        <el-select v-model="ruleForm.industryCategory" placeholder="请选择行业类别" size="mini">
                            <el-option label="区域一" value="shanghai"></el-option>
                            <el-option label="区域二" value="beijing"></el-option>
                        </el-select>
                    </el-form-item>
                    <el-form-item label="重要等级" prop="importantLevel">
                        <el-select v-model="ruleForm.importantLevel" placeholder="请选择重要等级" size="mini">
                            <el-option label="区域一" value="shanghai"></el-option>
                            <el-option label="区域二" value="beijing"></el-option>
                        </el-select>
                    </el-form-item>
                    <el-form-item label="单位等级" prop="unitLevel">
                        <el-select v-model="ruleForm.unitLevel" placeholder="请选择单位等级" size="mini">
                            <el-option label="区域一" value="shanghai"></el-option>
                            <el-option label="区域二" value="beijing"></el-option>
                        </el-select>
                    </el-form-item>
                    <el-form-item label="区域等级" prop="regionalGrade" class="regional-grade">
                        <el-select v-model="ruleForm.regionalGrade" placeholder="请选择区域等级" size="mini">
                            <el-option label="区域一" value="shanghai"></el-option>
                            <el-option label="区域二" value="beijing"></el-option>
                        </el-select>
                    </el-form-item>
                </el-form>
            </div>
            <div class="filter-section">
                <span class="fl title">其他信息</span>
            </div>
            <div class="institution-form">
                <el-form :model="ruleForm" :rules="rules" ref="ruleForm" label-width="100px">
                    <el-form-item label="经办人" prop="operator">
                        <el-input v-model="ruleForm.operator" size="mini"></el-input>
                    </el-form-item>
                    <el-form-item label="年费" prop="annualFee">
                        <el-input v-model="ruleForm.annualFee" size="mini"></el-input>
                        万
                    </el-form-item>
                    <el-form-item label="电子资源经费" prop="resourcesFund">
                        <el-input v-model="ruleForm.resourcesFund" size="mini"></el-input>
                        万
                    </el-form-item>
                    <el-form-item label="采购时间" prop="procTime">
                        <el-input v-model="ruleForm.procTime" size="mini"></el-input>
                    </el-form-item>
                    <el-form-item label="采购级别" prop="proLevel">
                        <el-select v-model="ruleForm.proLevel" placeholder="请选择采购级别" size="mini">
                            <el-option label="区域一" value="shanghai"></el-option>
                            <el-option label="区域二" value="beijing"></el-option>
                        </el-select>
                    </el-form-item>
                    <el-form-item label="采购方式" prop="proMode">
                        <el-select v-model="ruleForm.proMode" placeholder="请选择采购方式" size="mini">
                            <el-option label="区域一" value="shanghai"></el-option>
                            <el-option label="区域二" value="beijing"></el-option>
                        </el-select>
                    </el-form-item>
                    <el-form-item label="采购途径" prop="proChannels">
                        <el-select v-model="ruleForm.proChannels" placeholder="请选择采购途径" size="mini">
                            <el-option label="区域一" value="shanghai"></el-option>
                            <el-option label="区域二" value="beijing"></el-option>
                        </el-select>
                    </el-form-item>
                    <el-form-item label="分配情况" prop="distributionStatus">
                        <el-select v-model="ruleForm.distributionStatus" placeholder="请选择分配情况" size="mini">
                            <el-option label="区域一" value="shanghai"></el-option>
                            <el-option label="区域二" value="beijing"></el-option>
                        </el-select>
                    </el-form-item>
                    <el-form-item label="审核状态" prop="auditStatus">
                        <el-select v-model="ruleForm.auditStatus" placeholder="请选择审核状态" size="mini">
                            <el-option label="区域一" value="shanghai"></el-option>
                            <el-option label="区域二" value="beijing"></el-option>
                        </el-select>
                    </el-form-item>
                    <el-form-item label="机构类型" prop="institutionType">
                        <el-select v-model="ruleForm.institutionType" placeholder="请选择机构类型" size="mini">
                            <el-option label="区域一" value="shanghai"></el-option>
                            <el-option label="区域二" value="beijing"></el-option>
                        </el-select>
                    </el-form-item>
                    <el-form-item label="跟进状态" prop="followStatus" class="follow-status">
                        <el-select v-model="ruleForm.followStatus" placeholder="请选择跟进状态" size="mini">
                            <el-option label="区域一" value="shanghai"></el-option>
                            <el-option label="区域二" value="beijing"></el-option>
                        </el-select>
                    </el-form-item>
                    <el-form-item label="备注信息" prop="note" class="form-textarea">
                        <el-input type="textarea" v-model="ruleForm.note" size="mini"></el-input>
                    </el-form-item>
                </el-form>
            </div>
        </div>
        <div class="btn-wrap">
            <el-button type="primary" @click="submitForm('ruleForm')">确定</el-button>
            <el-button @click="cancelForm()">取消</el-button>
        </div>
    </div>
</template>

<script>
    export default {
        name: "businessCreate",
        data() {
            return {
                ruleForm: {
                    insitituName: "",
                    instituAddress: "",
                    contact: "",
                    telephone: "",
                    workPhone: "",
                    provinces: "",
                    city: "",
                    postcode: "",
                    website: "",
                    institutionLevel: "",
                    industryCategory: "",
                    importantLevel: "",
                    unitLevel: "",
                    regionalGrade: "",
                    operator: "",
                    annualFee: "",
                    resourcesFund: "",
                    procTime: "",
                    proLevel: "",
                    proMode: "",
                    proChannels: "",
                    distributionStatus: "",
                    auditStatus: "",
                    institutionType: "",
                    followStatus: "",
                    note: "",
                },
                rules: {
                    insitituName: [
                        {required: true, message: '请输入机构名称', trigger: 'blur'}
                    ],
                    instituAddress: [
                        {required: true, message: '请输入机构地址', trigger: 'blur'}
                    ],
                    contact: [
                        {required: true, message: '请输入联系人', trigger: 'blur'},
                    ],
                    telephone: [
                        {required: true, message: '请输入手机', trigger: 'blur'}
                    ],
                    workPhone: [
                        {required: true, message: '请输入电话', trigger: 'blur'}
                    ],
                    provinces: [
                        {required: true, message: '请选择省份', trigger: 'change'},
                    ],
                    city: [
                        {required: true, message: '请选择城市', trigger: 'change'},
                    ],
                    institutionLevel: [
                        {required: true, message: '请选择机构级别', trigger: 'change'},
                    ],
                    industryCategory: [
                        {required: true, message: '请选择行业类别', trigger: 'change'},
                    ],
                    importantLevel: [
                        {required: true, message: '请选择重要级别', trigger: 'change'},
                    ],
                    unitLevel: [
                        {required: true, message: '请选择单位等级', trigger: 'change'},
                    ],
                    regionalGrade: [
                        {required: true, message: '请选择区域等级', trigger: 'change'},
                    ],
                    operator: [
                        {required: true, message: '请输入经办人', trigger: 'blur'},
                    ],
                    distributionStatus: [
                        {required: true, message: '请选择分配状况', trigger: 'change'},
                    ],
                    auditStatus: [
                        {required: true, message: '请选择审核状态', trigger: 'change'},
                    ],
                    institutionType: [
                        {required: true, message: '请选择机构类型', trigger: 'change'},
                    ],
                    followStatus: [
                        {required: true, message: '请选择跟进状态', trigger: 'change'},
                    ]
                }
            }
        },
        methods: {
            submitForm(formName) {
                this.$refs[formName].validate((valid) => {
                    if (valid) {
                        console.log('submit!');
                        this.jumpToDefault();
                    } else {
                        console.log('error submit!!');
                        return false;
                    }
                });
            },
            cancelForm() {
                this.jumpToDefault();
            },
            jumpToDefault() {
                this.$parent.curPath = 'default';
            }
        }
    }
</script>

<style lang="scss">
    @import "src/common/common.style";
    .business-create-template {
        background-color: #ffffff;
        width: 100%;
        height: 100%;
        position: relative;
        .return {
            position: absolute;
            top: 0;
            left: 15px;
            padding: 0;
        }
        .header {
            text-align: center;
        }
        .content {
            height: 85%;
            @include ofy-a();
            .filter-section {
                clear: both;
                border-bottom: 1px solid #ddd;
                padding-bottom: 25px;
                margin: 0 10px;
                padding-left: 5px;
                padding-right: 5px;
                .title {
                    font-size: $font-mn;
                    font-weight: 600;
                }
                .gray {
                    color: gray;
                }
            }
            .institution-form {
                padding-top: 10px;
                .el-form {
                    margin: 0 50px;
                    .el-form-item:not(.form-textarea) {
                        margin-bottom: 15px;
                        display: inline-block;
                        width: 50%;
                        .el-form-item__content {
                            @include fl();
                            margin-left: 0 !important;
                        }
                        .el-input {
                            width: 300px;
                        }
                    }
                    .regional-grade, .follow-status {
                        @include fl();
                    }
                    .form-textarea {
                        clear: both;
                        .el-textarea {
                            width: 80%;
                            float: left;
                            .el-textarea__inner {
                                min-height: 100px !important;
                            }
                        }
                    }
                }
            }
        }
        .btn-wrap {
            .el-button {
                width: 100px;
                margin: 0 50px;
            }
        }
    }
</style>